<!doctype html>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Hello, world!</title>
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <style>
        .bd-placeholder-img {
            font-size: 1.125rem;
            text-anchor: middle;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
        }

        @media (min-width: 768px) {
            .bd-placeholder-img-lg {
                font-size: 3.5rem;
            }
        }

        html,
        body {
            height: 100%;
        }

        body {
            padding-bottom: 40px;
            background-color: #fff;
        }

        .form-signin {
            width: 100%;
            max-width: 640px;
            margin: auto;
            padding: 15px;
        }

        .form-signin .checkbox {
            font-weight: 400;
        }

        .form-signin .form-control {
            position: relative;
            box-sizing: border-box;
            height: auto;
            padding: 10px;
            font-size: 16px;
        }

        .filedlabel {
            width: 90px !important;
        }

        .form-signin .form-control:focus {
            z-index: 2;
        }

        .form-signin input[type="email"] {
            margin-bottom: -1px;
            border-bottom-right-radius: 0;
            border-bottom-left-radius: 0;
        }

        .form-signin input[type="password"] {
            margin-bottom: 10px;
            border-top-left-radius: 0;
            border-top-right-radius: 0;
        }

        .sr-only2 {
            margin-top: 15px;
        }


        .logodiv img {
            width: 240px;
            margin: 0 auto;
            display: block;
        }

        .logodiv {
            text-align: center;
        }

        .logodiv h1 {
            font-size: 1.4rem;
            color: #03357a;
            margin-top: 20px;
            margin-bottom: 50px;
        }

        .logodiv h2 {
            font-size: 1.5rem;
            margin-bottom: 80px;
        }

        .list-group-item{
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .fgtpaws {
            text-align: center;
            margin-top: 10px;
        }

        .btn {
            padding-left: 0;
            padding-right: 0;
            margin-bottom: 15px;
        }

        label {
            font-size: 16px;
            margin-top: 20px;
            color: #999;
        }
    </style>
    <script type="text/javascript">
        var print_tags = [
            {
                "Company": "上海xxxx金属制品有限公司",
                "LabelNum": "2022-02399494/32132",
                "PackageID": "",
                "ShelfNum": "32132",
                "LotNum": "32132", //批号
                "PartNum": "2022-02399494",//物料
                "TranType": "",
                "TranQty": 1,
                "IUM": "",
                "FromWarehouseCode": "",
                "FromBinNum": "",
                "ToWarehouseCode": "",
                "ToBinNum": "",
                "TranDate": "", //日期
                "TranTime": 0,
                "PackNum": 0, //出货
                "PartDescription": "",
                "PackLine": 0,
                "PackSlip": "",//收货
                "ProdCode":"6FB",//Product Group
                "ExpiryDate":"DD-MM-YYYY",//Product Group:
                "PONum": 0, //采购单
                "POLine": 0,
                "PORelNum": 0,
                "JobNum": 0,//工單
                "AssemblySeq": 0,
                "JobSeq": 0,
                "OrderNum": 0,//訂單
                "OrderLine": 0,
                "OrderRelNum": 0,
            }
        ];

        var Serial = [
            {
                "type": 1,
                "LabelNum": "2022-02399494/32132",
                "SerialNumber": "192019012",
                "tag":print_tags[0],
            },
            {
                "type": 2,
                "LabelNum": "2022-02399494/32132",
                "SerialNumber": "192019013",
                "tag":print_tags[0],
            },
        ]
    </script>
</head>

<body>
    <div id="app">
        <div class="form-signin form-group1">

            <div class="logodiv">
                <img class="bannerlogo" src="../image/logo.jpeg">
            </div>

            <div id="temp1">
                <label>{{lan['printer']}}-{{lan['Carton_Label']}}-{{lan['Template']}}</label>
                <div class="d-flex bd-highlight align-items-center mt-2">
                    <div class="p-2 flex-grow-1 bd-highlight">
                        <select id="site-content" v-model="dyparam.carton_label_tamp"
                            class="form-select form-control-theme form-control" :placeholder="lan['Site_placeholder']"
                            aria-label="Please select site">
                            <option value="mylabel5">arco</option>
                        </select>
                    </div>
                </div>

            </div>

            <div id="temp3">
                <label>{{lan['printer']}}-{{lan['SN_Label']}}-{{lan['Template']}}</label>
                <div class="d-flex bd-highlight align-items-center mt-2">
                    <div class="p-2 flex-grow-1 bd-highlight">
                        <select id="site-content" v-model="dyparam.sn_label_tamp"
                            class="form-select form-control-theme form-control" :placeholder="lan['Site_placeholder']"
                            aria-label="Please select site">
                            <option value="mylabel4">arco-97*47</option>
                        </select>
                    </div>
                </div>

            </div>


            <div id="acro1" v-show="dayin == 'arco'">
                <label>{{lan['printer']}}-{{lan['Carton_Label']}}</label>
                <div class="d-flex bd-highlight align-items-center mt-2">
                    <div class="p-2 flex-grow-1 bd-highlight">
                        <input type="text" id="cartonIp-input" style="font-size: 12px;" @keyup="filterCartonIp"  v-model="dyparam.arcoip1"
                            class="form-control form-control-theme" placeholder="wifi ip">
                        <ul style="position: absolute;z-index: 111 ;width:100%;" class="list-group" v-show="showCartonIp">
                            <li class="list-group-item" v-for="(item,index) in filteredCartonIp" >
                                <div style="width: 80%;" @click="selectCartonIp(item)">{{ item }}</div>
                                <img @click="removeCartonIp(index)"  src="../image/x.svg" alt="Bootstrap" width="32" height="32">
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="d-flex bd-highlight align-items-center mt-2">
                    <div class="p-2 flex-grow-1 bd-highlight">
                        <input type="text" id="cartonPort-input" style="font-size: 12px;" @keyup="filterCartonPort" v-model="dyparam.arcoport1"
                            class="form-control form-control-theme" placeholder="wifi port">
                        <ul style="position: absolute;z-index: 111 ;width:100%;" class="list-group" v-show="showCartonPort">
                            <li class="list-group-item" v-for="(item,index) in filteredCartonPort" >
                                <div style="width: 80%;" @click="selectCartonPort(item)">{{ item }}</div>
                                <img @click="removeCartonPort(index)"  src="../image/x.svg" alt="Bootstrap" width="32" height="32">
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
          
            <div id="acro3" v-show="dayin == 'arco'">
                <label>{{lan['printer']}}-{{lan['SN_Label']}}</label>
                <div class="d-flex bd-highlight align-items-center mt-2">
                    <div class="p-2 flex-grow-1 bd-highlight">
                        <input type="text" id="api" style="font-size: 12px;" @keyup="filterSnIp" v-model="dyparam.arcoip3"
                            class="form-control form-control-theme" placeholder="wifi ip">
                        <ul style="position: absolute;z-index: 111 ;width:100%;" class="list-group" v-show="showSnIp">
                            <li class="list-group-item" v-for="(item,index) in filteredSnIp" >
                                <div style="width: 80%;" @click="selectSnIp(item)">{{ item }}</div>
                                <img @click="removeSnIp(index)"  src="../image/x.svg" alt="Bootstrap" width="32" height="32">
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="d-flex bd-highlight align-items-center mt-2">
                    <div class="p-2 flex-grow-1 bd-highlight">
                        <input type="text" id="api" style="font-size: 12px;" @keyup="filterSnPort" v-model="dyparam.arcoport3"
                            class="form-control form-control-theme" placeholder="wifi port">
                        <ul style="position: absolute;z-index: 111 ;width:100%;" class="list-group" v-show="showSnPort">
                            <li class="list-group-item" v-for="(item,index) in filteredSnPort" >
                                <div style="width: 80%;" @click="selectSnPort(item)">{{ item }}</div>
                                <img @click="removeSnPort(index)"  src="../image/x.svg" alt="Bootstrap" width="32" height="32">
                            </li>
                        </ul>
                    </div>
                </div>
            </div>


            <div class="form-group row action-row">
               
                <div class="col-4">
                    <button type="button" tapmode="" onclick="save();" class="btn btn-primary btn-action">{{lan['Save_setting']}}</button>
                </div>
                <div class="col-4">
                    <button type="button" tapmode="" onclick="open_printpage(print_tags,1,1);"
                        class="btn btn-primary btn-action">{{lan['Carton_Label_test']}}</button>
                </div>
                <!-- <div class="col-4">
                    <button type="button" tapmode="" onclick="open_printpage(print_tags,1,2);"
                        class="btn btn-primary btn-action">{{lan['Pallet_Label_test']}}</button>
                </div> -->

                <div class="col-4">
                    <button type="button" tapmode="" onclick="open_printpage(Serial,1,3);"
                        class="btn btn-primary btn-action">{{lan['SKU_Label_test']}}</button>
                </div>
                
            </div>




        </div>

        <div class="copyright mt-2 w-100">
            <div class="row" :gutter="10">
                <div  class="col-5" style="text-align: right;">{{lan['Version']}}：</div>
                <div  class="col-7">{{appversion}}</div>
                <div  class="col-5"  style="text-align: right;">{{lan['Site']}}：</div>
                <div  class="col-7">{{SiteName}}</div>
                <div  class="col-5"  style="text-align: right;">{{lan['Company']}}：</div>
                <div  class="col-7">{{CompanyName}}</div>
            </div>
        </div>



        <div id="mylabel1" class="mylabel1">

            <h5 class="text-center d-flex"><span id="CompanyName">上海xxxx金属制品有限公司</span> <img class="printlogo"
                    src="../image/printlogo.png"></h5>



            <div class="row">
                <div class="col-6 labeltxt"><span class="title">物料号：</span>2022-02399494</div>
                <div class="col-6 labeltxt"><span class="title">工单号：</span>006620</div>
                <div class="col-12 labeltxt"><span class="title">物料描述：</span>2022-02399494</div>
                <div class="col-4 labeltxt"><span class="title">数量：</span>100</div>
                <div class="col-5 labeltxt"><span class="title">批次号：</span>220831</div>
                <div class="col-3 labeltxt"><span class="title">版本：</span>A</div>
                <div class="col-12">
                    <div class="qrcode1" id="qrcode1"></div>
                </div>
                <div class="col-12 labeltxt text-center">
                    PR-2022-192019013
                </div>
            </div>

        </div>

        <div id="mylabel4" class="mylabel4">
            <svg id="barcode3"></svg>
            <div class="row">
                <div class="col-12 labeltxt"><span class="title">工单号：</span>2022-02399494</div>
                <div class="col-12 labeltxt"><span class="title">批次号：</span>006620</div>
                <div class="col-12 labeltxt"><span class="title">物料号：</span>2022-02399494</div>
                <div class="col-12 labeltxt"><span class="title">版本：</span>A</div>
                <div class="col-12 labeltxt"><span class="title">工单号：</span>2022-02399494</div>
                <div class="col-12 labeltxt"><span class="title">批次号：</span>006620</div>
                <div class="col-12 labeltxt"><span class="title">物料号：</span>2022-02399494</div>
                <div class="col-12 labeltxt"><span class="title">版本：</span>A</div>
                <div class="col-12 labeltxt"><span class="title">版本：</span>A</div>

            </div>
            <img class="printlogo2" src="../image/logo.jpeg">
            <div class="qrcode2" id="qrcode2"></div>

        </div>



    </div>
</body>
<script id="post-template" type="text/html">
    <option>請選擇公司</option>
    {{ for(var i=0,len=it.length; i < len; i++) { }}
  
           <option value="{{= it[i].Company1 }}">{{= it[i].Name }}</option>
	{{ } }}
</script>
<script type="text/javascript" src="../script/lang.js"></script>
<script type="text/javascript" src="../script/doT.js"></script>
<script type="text/javascript" src="../script/base64.js"></script>
<script type="text/javascript" src="../script/JsBarcode.all.min.js"></script>
<script type="text/javascript" src="../script/qrcode.min.js"></script>
<script type="text/javascript" src="../script/html2canvas.min.js"></script>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/vue.min.js"></script>
<script type="text/javascript" src="../script/jquery.min.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript">
    
    const app = new Vue({
        el: '#app',
        data: {
            appversion:"",
            SiteName:"",
            CompanyName:"",
            checkkey: 'en-hk',
            dyparam: {
                "carton_label_tamp": "mylabel5",
                "sn_label_tamp": "mylabel4",
                "arcoip1": "192.168.1.6",
                "arcoport1": 9100,
                "arcoip2": "192.168.1.6",
                "arcoport2": 9100,
                "arcoip3": "192.168.1.6",
                "arcoport3": 9100,
            },
            //箱条码IP操作值储存
            cartonIpList: [],
            filteredCartonIp:[],
            showCartonIp: false,
            //箱条码端口操作值储存
            cartonPortList: [],
            filteredCartonPort:[],
            showCartonPort: false,
            //托条码IP操作值储存
            palletIpList: [],
            filteredPalletIp:[],
            showPalletIp: false,
            //托条码端口操作值储存
            palletPortList: [],
            filteredPalletPort:[],
            showPalletPort: false,

            //序列号IP操作值储存
            snIpList: [],
            filteredSnIp:[],
            showSnIp: false,
            //序列号端口操作值储存
            snPortList: [],
            filteredSnPort:[],
            showSnPort: false,
            dayin: modeldayin,
        },
        watch: {
            'dyparam.arcoip1': function(newKeyword) {
            // 将关键字保存到本地存储中
            localStorage.setItem('searchCartonIp', JSON.stringify(this.cartonIpList.concat(newKeyword)));
            },
            'dyparam.arcoport1': function(newKeyword) {
            // 将关键字保存到本地存储中
            localStorage.setItem('searchCartonPort', JSON.stringify(this.cartonPortList.concat(newKeyword)));
            },
            'dyparam.arcoip2': function(newKeyword) {
            // 将关键字保存到本地存储中
            localStorage.setItem('searchPalletIp', JSON.stringify(this.palletIpList.concat(newKeyword)));
            },
            'dyparam.arcoport2': function(newKeyword) {
            // 将关键字保存到本地存储中
            localStorage.setItem('searchPalletPort', JSON.stringify(this.palletPortList.concat(newKeyword)));
            },
            'dyparam.arcoip3': function(newKeyword) {
            // 将关键字保存到本地存储中
            localStorage.setItem('searchSnIp', JSON.stringify(this.snIpList.concat(newKeyword)));
            },
            'dyparam.arcoport3': function(newKeyword) {
            // 将关键字保存到本地存储中
            localStorage.setItem('searchSnPort', JSON.stringify(this.snPortList.concat(newKeyword)));
            }
        },
        mounted() {
            init_qrcode();
            $("#CompanyName").html("上海xxxx金属制品有限公司");
            //this.dayin = "zebra";
        },
        created(){
            // 获取历史查询数据
            let searchCartonIp = localStorage.getItem('searchCartonIp');
            if (searchCartonIp) {
                this.cartonIpList = Array.from(new Set(JSON.parse(searchCartonIp)));
            }
            let searchCartonPort = localStorage.getItem('searchCartonPort');
            if (searchCartonPort) {
                this.cartonPortList = Array.from(new Set(JSON.parse(searchCartonPort)));
            }
            let searchPalletIp = localStorage.getItem('searchPalletIp');
            if (searchCartonPort) {
                this.palletIpList = Array.from(new Set(JSON.parse(searchPalletIp)));
            }
            let searchPalletPort = localStorage.getItem('searchPalletPort');
            if (searchPalletPort) {
                this.palletPortList = Array.from(new Set(JSON.parse(searchPalletPort)));
            }
            let searchSnIp = localStorage.getItem('searchSnIp');
            if (searchCartonPort) {
                this.snIpList = Array.from(new Set(JSON.parse(searchSnIp)));
            }
            let searchSnPort = localStorage.getItem('searchSnPort');
            if (searchSnPort) {
                this.snPortList = Array.from(new Set(JSON.parse(searchSnPort)));
            }
        },
        methods: {
            //筛选打印机箱条码ip
            filterCartonIp: function() {
                let keyword = this.dyparam.arcoip1;
                this.showCartonIp = true;
                this.filteredCartonIp = this.cartonIpList.filter(function(item) {
                    return item.indexOf(keyword) !== -1;
                });
            },
            // 选择打印机历史箱条码ip
            selectCartonIp: function(item) {
                this.dyparam.arcoip1 = item;
                this.showCartonIp = false;
            },
            // 删除打印机历史箱条码ip
            removeCartonIp: function(index) {
                this.cartonIpList.splice(index, 1);
                this.showCartonIp = false;
                localStorage.setItem('searchCartonIp', JSON.stringify(this.cartonIpList));
            },
            //筛选打印机箱条码度端口
            filterCartonPort: function() {
                let keyword = this.dyparam.arcoport1;
                this.showCartonPort = true;
                this.filteredCartonPort = this.cartonPortList.filter(function(item) {
                    return item.indexOf(keyword) !== -1;
                });
            },
            // 选择打印机历史箱条码端口
            selectCartonPort: function(item) {
                this.dyparam.arcoport1 = item;
                this.showCartonPort = false;
            },
            // 删除打印机历史箱条码端口
            removeCartonPort: function(index) {
                this.cartonPortList.splice(index, 1);
                this.showCartonPort = false;
                localStorage.setItem('searchCartonPort', JSON.stringify(this.cartonPortList));
            },
            //筛选打印机托码ip
            filterPalletIp: function() {
                let keyword = this.dyparam.arcoip2;
                this.showPalletIp = true;
                this.filteredPalletIp = this.palletIpList.filter(function(item) {
                    return item.indexOf(keyword) !== -1;
                });
            },
            // 选择打印机历史托码ip
            selectPalletIp: function(item) {
                this.dyparam.arcoip2 = item;
                this.showPalletIp = false;
            },
            // 删除打印机历史托码ip
            removePalletIp: function(index) {
                this.palletIpList.splice(index, 1);
                this.showPalletIp = false;
                localStorage.setItem('searchPalletIp', JSON.stringify(this.palletIpList));
            },
            //筛选打印机托码端口
            filterPalletPort: function() {
                let keyword = this.dyparam.arcoport2;
                this.showPalletPort = true;
                this.filteredPalletPort = this.palletPortList.filter(function(item) {
                    return item.indexOf(keyword) !== -1;
                });
            },
            // 选择打印机历史托码端口
            selectPalletPort: function(item) {
                this.dyparam.arcoport2 = item;
                this.showPalletPort = false;
            },
            // 删除打印机历史托码端口
            removePalletPort: function(index) {
                this.palletPortList.splice(index, 1);
                this.showPalletPort = false;
                localStorage.setItem('searchPalletPort', JSON.stringify(this.palletPortList));
            },
             //筛选打印机序列号ip
             filterSnIp: function() {
                let keyword = this.dyparam.arcoip3;
                this.showSnIp = true;
                this.filteredSnIp = this.snIpList.filter(function(item) {
                    return item.indexOf(keyword) !== -1;
                });
            },
            // 选择打印机历史序列号ip
            selectSnIp: function(item) {
                this.dyparam.arcoip3 = item;
                this.showSnIp = false;
            },
            // 删除打印机历史序列号ip
            removeSnIp: function(index) {
                this.snIpList.splice(index, 1);
                this.showSnIp = false;
                localStorage.setItem('searchSnIp', JSON.stringify(this.snIpList));
            },
            //筛选打印机序列号端口
            filterSnPort: function() {
                let keyword = this.dyparam.arcoport3;
                this.showSnPort = true;
                this.filteredSnPort = this.snPortList.filter(function(item) {
                    return item.indexOf(keyword) !== -1;
                });
            },
            // 选择打印机历史序列号端口
            selectSnPort: function(item) {
                this.dyparam.arcoport3 = item;
                this.showSnPort = false;
            },
            // 删除打印机历史序列号端口
            removeSnPort: function(index) {
                this.snPortList.splice(index, 1);
                this.showSnPort = false;
                localStorage.setItem('searchSnPort', JSON.stringify(this.snPortList));
            }

        }
    });

    apiready = function () {
        api.parseTapmode();
        back_listen();
        // alert(modeldayin);
        //getlan();
        //app.customapi = "192.168.2.89";
        var checkkey = localStorage.getItem('lkey');
        app.checkkey = checkkey ? checkkey : 'en-hk';
        userinfo = get_user_info();
        app.appversion=api.appVersion;
        app.SiteName=userinfo.SiteName;
        app.CompanyName=userinfo.CompanyName;
        var param = get_prefs_data("dyparam");
        if (param) {
            app.dyparam = param;
        }
        
        /*
        api.addEventListener({
            name: 'print_connected'
        }, function (ret, err) {
            api.alert({
                title: 'Tips',
                msg: '连接成功',
            }, function (ret, err) {

            });
        });
        */

    }

    function init_qrcode() {
        // setting = get_prefs_data('setting');
        var qrcode = new QRCode(document.getElementById("qrcode1"), {
            width: 250,
            height: 250,
            colorDark: "#000000",
            colorLight: "#ffffff",
            correctLevel: QRCode.CorrectLevel.H
        });
        qrcode.makeCode("PR-2022-192019013");


        JsBarcode("#barcode", "PR-2022-192019013", { height: 100, displayValue: false });

        JsBarcode("#barcode2", "PR-2022-192019013", { height: 100, displayValue: false });
        JsBarcode("#barcode3", "PR-2022-192019013", { height: 100, displayValue: false });


        var qrcode2 = new QRCode(document.getElementById("qrcode2"), {
            width: 100,
            height: 100,
            colorDark: "#000000",
            colorLight: "#ffffff",
            correctLevel: QRCode.CorrectLevel.H
        });
        qrcode2.makeCode("PR-2022-192019013");
        /*

        JsBarcode("#barcode", "PR-2022-192019013", {
            format: "pharmacode",
            height: 40,
            displayValue: false
        });
        */

    }


    function shareapp() {
        $("#mylabel1").attr("class", "mylabel1 mylbshow");
        $("#mylabel1").trigger("click");
        window.pageYOffset = 0;
        document.documentElement.scrollTop = 0
        document.body.scrollTop = 0


        html2canvas(document.querySelector("#mylabel1")).then(function (canvas) {

            var bsimg = convertCanvasToImage(canvas);
            var k = bsimg.replace(/^.*?,/, '');
            var param = {};
            param.bsimg = k;
            $("#mylabel1").attr("class", "mylabel1");
            console.log(bsimg);
            console.log(k);
            wifiprint(1, k, 1)


        });



    }

    function shareapp2() {
        $("#mylabel2").attr("class", "mylabel2 mylbshow");
        $("#mylabel2").trigger("click");
        window.pageYOffset = 0;
        document.documentElement.scrollTop = 0
        document.body.scrollTop = 0


        html2canvas(document.querySelector("#mylabel2")).then(function (canvas) {

            var bsimg = convertCanvasToImage(canvas);
            var k = bsimg.replace(/^.*?,/, '');
            var param = {};
            $("#mylabel2").attr("class", "mylabel2");
            param.bsimg = k;
            wifiprint(2, k, 1)
            console.log(k);

        });



    }


    function shareapp3() {
        $("#mylabel3").attr("class", "mylabel3 mylbshow");
        $("#mylabel3").trigger("click");
        window.pageYOffset = 0;
        document.documentElement.scrollTop = 0
        document.body.scrollTop = 0


        html2canvas(document.querySelector("#mylabel3")).then(function (canvas) {

            var bsimg = convertCanvasToImage(canvas);
            var k = bsimg.replace(/^.*?,/, '');
            var param = {};
            $("#mylabel3").attr("class", "mylabel3");
            param.bsimg = k;
            wifiprint2(1, k, 1)
            console.log(k);

        });



    }


    function convertCanvasToImage(canvas) {
        var image = new Image();
        image.src = canvas.toDataURL("image/jpg");
        return image.src;
    }



    function wifiprint2(type, imgstr, num) {

        var moduleTsc = api.require('moduleZebra');
        alert(1);
        moduleTsc.print({ "type": type, "imgstr": imgstr, "print_num": num }, function (ret, err) {
            alert(2);
            alert_debug(ret);
            if (ret) {
                if (ret.status == 1) {
                    api.alert({
                        title: 'Tips',
                        msg: '成功发送打印指令',
                    }, function (ret, err) {

                    });
                } else {
                    hideProgress();
                    errMassage(ret.msg)
                }
            }
        });
    }



    function wifiprint(type, imgstr, num) {

        var moduleTsc = api.require('moduleTsc');
        moduleTsc.print({ "type": type, "imgstr": imgstr, "print_num": num }, function (ret, err) {
            if (ret) {
                if (ret.status == 1) {
                    api.alert({
                        title: 'Tips',
                        msg: '成功发送打印指令',
                    }, function (ret, err) {

                    });
                } else {
                    hideProgress();
                    errMassage(ret.msg)
                }
            }
        });
    }


    function connect() {


        if (app.dyparam.ip1 == '') {
            api.toast({
                msg: "请输入打印机(60*40)ip",
                location: 'middle'
            });
            return false;
        }

        if (app.dyparam.port1 == '') {
            api.toast({
                msg: "请输入打印机(60*40)端口",
                location: 'middle'
            });
            return false;
        }

        var jsfun = 'wificonnect("' + app.dyparam.ip1 + '",' + app.dyparam.port1 + ');';

        api.execScript({
            name: 'root',
            script: jsfun
        });
        return;


        var moduleTsc = api.require('moduleTsc');
        moduleTsc.connect({ "ip": app.dyparam.ip1, "port": parseInt(app.dyparam.port1) }, function (ret, err) {
            if (ret) {
                if (ret.status == 1) {
                    api.alert({
                        title: 'Tips',
                        msg: '连接成功',
                    }, function (ret, err) {

                    });
                }
                if (ret.status == 2) {
                    hideProgress();
                    errMassage(ret.msg)
                }
            }
        });



    }

    function save() {
        if (app.dyparam.ip1 == '') {
            api.toast({
                msg: "请输入打印机(60*40)ip",
                location: 'middle'
            });
            return false;
        }

        if (app.dyparam.port1 == '') {
            api.toast({
                msg: "请输入打印机(60*40)端口",
                location: 'middle'
            });
            return false;
        }

        if (app.dyparam.ip2 == '') {
            api.toast({
                msg: "请输入打印机(100*140)ip",
                location: 'middle'
            });
            return false;
        }

        if (app.dyparam.port2 == '') {
            api.toast({
                msg: "请输入打印机(100*140)端口",
                location: 'middle'
            });
            return false;
        }

        if (app.dyparam.mac == '') {
            api.toast({
                msg: "请输入打印机蓝牙地址",
                location: 'middle'
            });
            return false;
        }



        api.setPrefs({
            key: 'dyparam',
            value: app.dyparam
        });

        api.toast({
            msg: lan['Save_successfully'],
            location: 'middle'
        });


    }


    function connect2() {


        if (app.dyparam.ip2 == '') {
            api.toast({
                msg: "请输入打印机(100*140)ip",
                location: 'middle'
            });
            return false;
        }

        if (app.dyparam.port2 == '') {
            api.toast({
                msg: "请输入打印机(100*140)端口",
                location: 'middle'
            });
            return false;
        }

        var jsfun = 'wificonnect("' + app.dyparam.ip2 + '",' + app.dyparam.port2 + ');';
        api.execScript({
            name: 'root',
            script: jsfun
        });
        return;

        var moduleTsc = api.require('moduleTsc');
        moduleTsc.connect({ "ip": app.dyparam.ip2, "port": parseInt(app.dyparam.port2) }, function (ret, err) {
            if (ret) {
                if (ret.status == 1) {
                    api.alert({
                        title: 'Tips',
                        msg: '连接成功',
                    }, function (ret, err) {

                    });
                }
                if (ret.status == 2) {
                    hideProgress();
                    errMassage(ret.msg)
                }
            }
        });



    }



    function connect3() {


        if (app.dyparam.mac == '') {
            api.toast({
                msg: "请输入打印机蓝牙地址",
                location: 'middle'
            });
            return false;
        }



        var jsfun = 'wificonnect2("' + app.dyparam.mac + '");';
        api.execScript({
            name: 'root',
            script: jsfun
        });




    }

</script>

</html>